package com.kingmed.kmss.common.vo.api;


import com.kingmed.kmss.common.enums.base.code.ApiResultCode;

public class ApiCommonResponseHelper {

    public ApiCommonResponseHelper() {
    }

    public static <T> ApiCommonResponse<T> success() {
        ApiCommonResponse response = new ApiCommonResponse();
        response.setCode(ApiResultCode.SUCCESS.getCode());
        response.setMessage(ApiResultCode.SUCCESS.getMessage());
        return response;
    }

    public static <T> ApiCommonResponse<T> success(String message) {
        ApiCommonResponse response = new ApiCommonResponse();
        response.setCode(ApiResultCode.SUCCESS.getCode());
        response.setMessage(message);
        return response;
    }

    public static <T> ApiCommonResponse<T> success(T result) {
        ApiCommonResponse response = new ApiCommonResponse();
        response.setCode(ApiResultCode.SUCCESS.getCode());
        response.setMessage(ApiResultCode.SUCCESS.getMessage());
        response.setData(result);
        return response;
    }

    public static <T> ApiCommonResponse<T> success(String message, T result) {
        ApiCommonResponse response = new ApiCommonResponse();
        response.setCode(ApiResultCode.SUCCESS.getCode());
        response.setMessage(message);
        response.setData(result);
        return response;
    }

    public static <T> ApiCommonResponse<T> fail() {
        ApiCommonResponse response = new ApiCommonResponse();
        response.setCode(ApiResultCode.FAILED.getCode());
        response.setMessage(ApiResultCode.FAILED.getMessage());
        return response;
    }


    public static <T> ApiCommonResponse<T> fail(String message) {
        ApiCommonResponse response = new ApiCommonResponse();
        response.setCode(ApiResultCode.FAILED.getCode());
        response.setMessage(message);
        return response;
    }

    public static <T> ApiCommonResponse<T> fail(T result) {
        ApiCommonResponse response = new ApiCommonResponse();
        response.setCode(ApiResultCode.FAILED.getCode());
        response.setMessage(ApiResultCode.FAILED.getMessage());
        response.setData(result);
        return response;
    }

    public static <T> ApiCommonResponse<T> fail(String message, T result) {
        ApiCommonResponse response = new ApiCommonResponse();
        response.setCode(ApiResultCode.FAILED.getCode());
        response.setMessage(message);
        response.setData(result);
        return response;
    }

    public static <T> ApiCommonResponse<T> forbidden() {
        ApiCommonResponse response = new ApiCommonResponse();
        response.setCode(ApiResultCode.FORBIDDEN.getCode());
        response.setMessage(ApiResultCode.FORBIDDEN.getMessage());
        return response;
    }

    public static <T> ApiCommonResponse<T> unauthorized() {
        ApiCommonResponse response = new ApiCommonResponse();
        response.setCode(ApiResultCode.UNAUTHORIZED.getCode());
        response.setMessage(ApiResultCode.UNAUTHORIZED.getMessage());
        return response;
    }

    public static <T> ApiCommonResponse<T> reqValidateFailed() {
        ApiCommonResponse response = new ApiCommonResponse();
        response.setCode(ApiResultCode.REQ_VALIDATE_FAILED.getCode());
        response.setMessage(ApiResultCode.REQ_VALIDATE_FAILED.getMessage());
        return response;
    }

    public static <T> ApiCommonResponse<T> reqValidateFailed(String message) {
        ApiCommonResponse response = new ApiCommonResponse();
        response.setCode(ApiResultCode.REQ_VALIDATE_FAILED.getCode());
        response.setMessage(message);
        return response;
    }

    public static <T> ApiCommonResponse<T> parsingDataFailed() {
        ApiCommonResponse response = new ApiCommonResponse();
        response.setCode(ApiResultCode.PARSING_DATA_FAILED.getCode());
        response.setMessage(ApiResultCode.PARSING_DATA_FAILED.getMessage());
        return response;
    }


}
